﻿using System;
using System.Text;
using MuYue.ORM;

namespace MuYue
{
    /// <summary>
    /// 答题服务器的配置信息
    /// </summary>
    public static class Configuration
    {
        /// <summary>
        /// 配置获取封装方法
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="key"></param>
        /// <param name="defaultValue"></param>
        /// <returns></returns>
        public static string TryGetValue(string domain, string key, string defaultValue) {
            return configManager.TryGetValue(domain, key, defaultValue);
        }
        /// <summary>
        /// 配置文件解析器
        /// </summary>
        private static readonly XmlConfigManager configManager = new XmlConfigManager("./user/app.conf");
        /// <summary>
        /// 数据库提供程序
        /// </summary>
        public static readonly DbType DbProvider = (DbType)Enum.Parse(typeof(DbType), TryGetValue("ORM", "DbType", "SQLite"));
        /// <summary>
        /// 数据库进行自动解析的数据表名前缀
        /// </summary>
        public static readonly string OrmTableNamePrex = TryGetValue("ORM", "Prex_", "MuYurORM_");
        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        public static readonly string DbConnectionString = TryGetValue("ORM", "ConnectionString", "data source=data.db3;datetimeformat=CurrentCulture");
        /// <summary>
        /// 日志输出目录
        /// </summary>
        public static readonly string LogSavePath = TryGetValue("LogService", "SavePath", @".\user\log");

        /// <summary>
        /// 日志记录最低水平
        /// </summary>
        public static readonly Log.LogLevel LogSaveLowestLevel = (Log.LogLevel)Enum.Parse(typeof(Log.LogLevel), TryGetValue("LogService", "LowestLevel", "警告"));
    }
}
